package sketch.generator;

import java.util.List;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class SubsetValueGeneratorTest extends TestCase {
	
	public static Test suite() {
		return new TestSuite(SubsetValueGeneratorTest.class);
	}
	
	public void testNormalGenerator() {
		System.out.println("---- testing normal ---");
		SubsetValueGenerator generator = new SubsetValueGenerator(1, 2, 3, 4);
		assertTrue(generator.raw_data_size == 4);
		assertTrue(generator.subset_num == 16);
		assertTrue(generator.current_data == null);
		assertTrue(generator.current_set_index == 0);
		
		int count = 0;
		while(generator.hasNextValue()) {
			List<Integer> ints = generator.nextValue();
			System.out.println(ints);
			count++;
		}
		assertTrue(count == 16);
	}
	
	public void testEmptySet() {
		System.out.println("---- testing empty ---");
		SubsetValueGenerator generator = new SubsetValueGenerator();
		assertTrue(generator.raw_data_size == 0);
		assertTrue(generator.subset_num == 1);
		assertTrue(generator.current_data == null);
		assertTrue(generator.current_set_index == 0);
		
		int count = 0;
		while(generator.hasNextValue()) {
			List<Integer> ints = generator.nextValue();
			System.out.println(ints);
			count++;
		}
		assertTrue(count == 1);
	}
	
	public void testReset() {
		System.out.println("---- testing reset ---");
		SubsetValueGenerator generator = new SubsetValueGenerator(1, 2, 3, 4);
		assertTrue(generator.raw_data_size == 4);
		assertTrue(generator.subset_num == 16);
		assertTrue(generator.current_data == null);
		assertTrue(generator.current_set_index == 0);
		
		int count = 0;
		while(generator.hasNextValue()) {
			List<Integer> ints = generator.nextValue();
			System.out.println(ints);
			count++;
		}
		assertTrue(count == 16);
		
		generator.reset();
		
		System.out.println("---- testing normal after resetting ---");
		assertTrue(generator.raw_data_size == 4);
		assertTrue(generator.subset_num == 16);
		assertTrue(generator.current_data == null);
		assertTrue(generator.current_set_index == 0);
		
		count = 0;
		while(generator.hasNextValue()) {
			List<Integer> ints = generator.nextValue();
			System.out.println(ints);
			count++;
		}
		assertTrue(count == 16);
	}
}
